// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

AndroidItem {
    id: _root
    width: 720 * viewScale
    height: 1280 * viewScale
    color: "#88000000"
    visible: false

    property variant screenshotPath: []                  //スクリーンショット
    property int takeDuration: 200
    property int hideDuration: 200

    property real firstWidth: 550 * viewScale           //撮影直後の幅
    property real firstHeight: 953 * viewScale          //撮影直後の高さ

    signal finished()

    function takeScreenShot(){
        visible = true;
        _anim.start();
    }

    Image{
        id: _frame
        x: -11
        y: -11
        width: (_root.width + 43) * viewScale
        height: (_root.height + 43) * viewScale
        source: "images/screenshot_in_frame.png"

        Image{
            id: _screenshot
            width: _frame.width
            height: _frame.height
            cache: false
            source: screenshotPath[0]
        }
    }

    //タイマーで消える時間を測る
    Timer{
        id: _hideTimer
        interval: 1000
        repeat: false
        running: false
        onTriggered: {
            _hideTimer.stop();
            _anim2.start();
        }
    }

    //最初のアニメーション
    SequentialAnimation{
        id: _anim
        running: false
        ParallelAnimation{
            NumberAnimation{
                target: _frame
                property: "width"
                from: width
                to: _root.firstWidth
                duration: takeDuration
            }
            NumberAnimation{
                target: _frame
                property: "x"
                from: 0
                to: (_root.width - _root.firstWidth) / 2
                duration: takeDuration
            }
            NumberAnimation{
                target: _frame
                property: "height"
                from: height
                to: _root.firstHeight
                duration: takeDuration
            }
            NumberAnimation{
                target: _frame
                property: "y"
                from: 0
                to: (_root.height - _root.firstHeight) / 2
                duration: takeDuration
            }
        }
        ScriptAction{
            script: {
                _hideTimer.start();
            }
        }
    }

    //消えてくときのアニメーション
    SequentialAnimation{
        id: _anim2
        running: false
        ParallelAnimation{
            NumberAnimation{
                target: _frame
                property: "width"
                //from: width
                to: 0
                duration: hideDuration
            }
            NumberAnimation{
                target: _frame
                property: "height"
                //from: height
                to: 0
                duration: hideDuration
            }
        }
        ScriptAction{
            script: {
                _root.visible = false;
                _root.finished();
            }
        }
    }

    states: [
        State {
            name: "Land"
            when: !isPortrait
            PropertyChanges {
                target: _root
                firstWidth: 953 * viewScale
                firstHeight: 550 * viewScale
            }
            PropertyChanges {
                target: _frame
                source: "images/screenshot_in_frame_land.png"
            }
            PropertyChanges {
                target: _screenshot
                source: screenshotPath[1]
            }
        }
    ]


}
